package jc16;
/*本类用于测试Runnable*/
public class fangfa2 {
    public static void main(String[] args) {
        myjihe it = new myjihe();
        Thread t = new Thread(it);
        Thread t1 = new Thread(it);
        Thread t2 = new Thread(it);
        Thread t3 = new Thread(it);
        Thread t4 = new Thread(it);
        t.start();
        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
class myjihe implements Runnable{
    int input = 100;
    Object o= new Object();
    @Override
    public void run() {
        while (true){
            synchronized (o) {
                if(input>0){
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "=" + input--);
                }
                if (input <= 0) break;
            }
        }
    }
}
